package com.jzhao.jpre.model.dao;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Date;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import com.nantian.iclient.platformplugin.errorHandler.func.init;
import com.jzhao.jpre.base.StringPublicDeal;
import com.jzhao.jpre.format.DataObjectMap;
import com.jzhao.jpre.format.DataObjectType;
import com.jzhao.jpre.model.PospSysParam;
import com.jzhao.jpre.model.PospTransInfo;
import com.jzhao.jpre.model.PmsPosActivetestLog;

public class PmsPosActivetestLogDao {
	protected JdbcTemplate jdbcTemplate;
	protected StringPublicDeal strPubDeal;

	public void setDataSource(DataSource dataSource) {
		jdbcTemplate = new JdbcTemplate(dataSource);
	}

	public void setStrPubDeal(StringPublicDeal strPubDeal) {
		this.strPubDeal = strPubDeal;
	}

	/**
	 * @author LYJ
	 * @param ppal
	 */
	public void insertLog(PmsPosActivetestLog ppal) {
		/*
		 * int iSeqId = 0; String seqSql =
		 * "SELECT SEQ_PMS_POS_ACTIVETEST_LOG.nextval FROM dual"; iSeqId =
		 * jdbcTemplate.queryForInt(seqSql);
		 * 
		 * String sql ="INSERT INTO PMS_POS_ACTIVETEST_LOG "
		 * +"(ID,RESPONSECODE,POSID,PRINTSTATUS,CONNECTSTATUS,"
		 * +"PASSWORDKEYSTATUS,CARDREADERSTATUS,PSAMSTATUS,"
		 * +"CONNECTSUCESSRATE,POSRUNSTATUS,"
		 * +"POSONLINETIME,APPLICATIONVERSION,PARAMETERVERSION,"
		 * +"PARAMETERDOWNLOADFLAG,APPLICATIONDOWNLOADFLAG,POSSN,"
		 * +"POSTERMINALID,MERCHANTCODE)"
		 * +" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		 */// Oracle

		String sql = "INSERT INTO PMS_POS_ACTIVETEST_LOG "
				+ "(RESPONSECODE,POSID,PRINTSTATUS,CONNECTSTATUS,"
				+ "PASSWORDKEYSTATUS,CARDREADERSTATUS,PSAMSTATUS,"
				+ "CONNECTSUCESSRATE,POSRUNSTATUS,"
				+ "POSONLINETIME,APPLICATIONVERSION,PARAMETERVERSION,"
				+ "PARAMETERDOWNLOADFLAG,APPLICATIONDOWNLOADFLAG,POSSN,"
				+ "POSTERMINALID,MERCHANTCODE)"
				+ " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		Object[] params = new Object[] { new Long(ppal.getResponsecode()),
				new Long(ppal.getPosid()), new Integer(ppal.getPrintstatus()),
				new Integer(ppal.getConnectstatus()),
				new Integer(ppal.getPasswordkeystatus()),
				new Integer(ppal.getCardreaderstatus()),
				new Integer(ppal.getPsamstatus()),
				new Long(ppal.getConnectsucessrate()),
				new Long(ppal.getPosrunstatus()), ppal.getPosonlinetime(),
				ppal.getApplicationversion(), ppal.getParameterversion(),
				new Integer(ppal.getParameterdownloadflag()),
				new Integer(ppal.getApplicationdownloadflag()),
				ppal.getPossn(), ppal.getPosterminalid(),
				ppal.getMerchantcode() };

		jdbcTemplate.update(sql, params);
	}
}